#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define str string
#define all(x) (x).begin(),(x).end()
#define ms(a,t) memset(a,t,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define db double
const int maxn = 1e6+10;
const int mod = 998244353;
const ll INF = 0x3f3f3f3f;
const db eps = 1e-7;
int n,k;
ll a[maxn],b[maxn];
bool check(ll x) {
	ll v = b[1],len = 1;
	for(int i = 2; i <= n; i++) {
		if(b[i] + v <= x && len < k) {
			len++; v = b[i];
		} else if(b[i] < v){
			v = b[i];
		}
	}
	return (len == k && v+b[1] <= x);
}
void Solve() {
	cin >> n >> k; ll mx = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i]; mx = max(mx,a[i]+a[i-1]);
	}
	ll v = *min_element(a+1,a+n+1);
	for(int i = 1; i <= n; i++) if(a[i] == v) {
		for(int j = 0; j < n; j++) {
			b[j+1] = a[(i+j-1)%n+1];
		}
		break;
	}
	ll l = 0,r = mx;
	while(l < r) {
		ll mid = (l + r) >> 1;
		if(check(mid)) {
			r = mid;
		} else {
			l = mid+1;
		}
	}
	cout<<l<<'\n';
}
int main() {
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
//	cin >> T;
	while(T--) {
		Solve();
	}
	return 0;
}
